/**
 * 
 */
package com.risetek.tft.service.impl;

import java.security.KeyPair;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.risetek.tft.service.RSAService;


/**
 * @author ht
 * 
 */

@Service
@Transactional(readOnly = true)
public class RSAServiceImpl implements RSAService {

	@Override
	public RSAPublicKey generateKey(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void removePrivateKey(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String decryptParameter(String paramString,
			HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		return null;
	}
/*
	public RSAPublicKey generateKey(HttpServletRequest request) {
		Assert.notNull(request);
		KeyPair localKeyPair = RSAUtils.generateKeyPair();
		RSAPublicKey localRSAPublicKey = (RSAPublicKey) localKeyPair
				.getPublic();
		RSAPrivateKey localRSAPrivateKey = (RSAPrivateKey) localKeyPair
				.getPrivate();
		HttpSession localHttpSession = request.getSession();
		localHttpSession.setAttribute("privateKey", localRSAPrivateKey);
		return localRSAPublicKey;
	}

	public void removePrivateKey(HttpServletRequest request) {
		Assert.notNull(request);
		HttpSession localHttpSession = request.getSession();
		localHttpSession.removeAttribute("privateKey");
	}

	public String decryptParameter(String name, HttpServletRequest request) {
		Assert.notNull(request);
		if (name != null) {
			HttpSession localHttpSession = request.getSession();
			RSAPrivateKey localRSAPrivateKey = (RSAPrivateKey) localHttpSession
					.getAttribute("privateKey");
			String str = request.getParameter(name);
			if ((localRSAPrivateKey != null) && (StringUtils.isNotEmpty(str)))
				return RSAUtils.decrypt(localRSAPrivateKey, str);
		}
		return null;
	}*/
}